/*
 * @Description: 移交申请单列表
 * @Author: Rfan
 * @Date: 2022-05-12 15:03:45
 * @LastEditTime: 2022-05-19 18:53:11
 */

import { useEffect, useState } from 'react';
import { Button, Space, Table } from 'antd';
import { useFormatMessage } from '@/utils/intlHelpers';

const { Column } = Table;
const PageList = () => {
  const formatMessage = useFormatMessage();
  const [selectItems, setSelectKey] = useState([]);
  const [loading, setLoading] = useState(false);
  const [total, setTotal] = useState(0);
  const [listQuery, setListQuery] = useState({
    pageNo: 1,
    pageSize: 10,
    params: {}
  });
  useEffect(() => {
    if (listQuery) {
      setLoading(false);
      setTotal(0);
      // getBatchList(listQuery)
      //   .then((res:any) => {
      //     setTotal(res?.totalCount);
      //   })
      //   .finally(() => {
      //     setLoading(false);
      //   });
    }
  }, [listQuery]);

  /**
   * @description 切换页码触发
   * @param {number} page 页码
   * @param {number} pageSize 每页条目数
   */
  const pageChange = (page: number, pageSize: number) => {
    setListQuery((state) => ({
      ...state,
      pageNo: page,
      pageSize
    }));
  };

  /**
   * @description : 表格选项相关设置
   * @param {number} selectedRowKeys 选择的项目的KEY
   */
  const onSelectChange = (selectedRowKeys: number[]) => {
    setSelectKey(selectedRowKeys);
  };

  /**
   * @description:  表格多选配置
   */
  const rowSelection = {
    selectItems,
    onChange: onSelectChange
  };

  return (
    <>
      <Table
        dataSource={[]}
        loading={loading}
        rowKey="id"
        rowSelection={rowSelection}
        bordered
        pagination={{
          current: listQuery.pageNo,
          pageSize: listQuery.pageSize,
          total,
          onChange: pageChange
        }}
      >
        <Column title="序号" dataIndex="id" key="id" align="center" />
        <Column title="标题" dataIndex="code" key="code" align="center" />
        <Column title="申请单号" dataIndex="name" key="name" align="center" />
        <Column title="状态" dataIndex="name" key="name" align="center" />
        <Column title="档案类型" dataIndex="name" key="name" align="center" />
        <Column title="移交人" dataIndex="name" key="name" align="center" />
        <Column title="移交日期" dataIndex="name" key="name" align="center" />
        <Column title="接收时间" dataIndex="name" key="name" align="center" />
        <Column title="审核人" dataIndex="name" key="name" align="center" />
        <Column title="审核时间" dataIndex="name" key="name" align="center" />
        <Column title="报告" dataIndex="name" key="name" align="center" />
        <Column title="移交的档案" dataIndex="name" key="name" align="center" />
        <Column
          title={formatMessage('tableAction')}
          key="action"
          align="center"
          width={200}
          render={(_text, record: any) => (
            <Space direction="vertical">
              <Button type="link" size="small">
                就收检测
              </Button>
              <Button type="link" size="small">
                审核
              </Button>
              <Button type="link" size="small">
                查看审核
              </Button>
            </Space>
          )}
        />
      </Table>
    </>
  );
};

export default PageList;
